$(function(){
	var count = 0;
	/********************账户注册失焦**********************/
	var nameStr = /^\d{11,11}$/;
	$("#content .right .phone").find("input").eq(0).blur(function(){
		var val = $(this).val()
		
		//$("#content .right .phone").find(".splast").html("用户名为4-16个数字")
		if (nameStr.test(val)) {
			$("#content .right .phone").find(".span1").html("OK").css("color","#090")
			count++
		}else{
			$("#content .right .phone").find(".span1").html("格式错误").css("color","#C8000A")
		}
		if(val==""){
			$("#content .right .phone").find(".span1").html("不能为空").css("color","#C8000A")
		}
	})
	
	/********************邮箱注册失焦**********************/
		var emailStr = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
		$("#content .right .yx").find("input").eq(0).blur(function(){
			
			var val = $(this).val()
			//var length = $(this).parent().index()
			//console.log(val,length)
		$("#content .right .yx").find("li").eq(0).find("span").html("请输入正确的邮箱")
			if (emailStr.test(val)) {
				$("#content .right .yx").find(".span2").html("OK").css("color","#090")
				count++
			}else{
				$("#content .right .yx").find(".span2").html("格式错误").css("color","#C8000A")
			}
			if(val==""){
				$("#content .right .yx").find(".span2").html("不能为空")
			}
		})
		
		
	/********************密码注册失焦**********************/
	var passString = /^([A-Z]|[a-z]|[0-9]){6,20}$/;
	$("#content .right .mima").find("input").eq(0).blur(function(){
		
		var val = $(this).val()
		//$("#fill ul").find("li").eq(2).find("span").html("为了用户安全，建议至少为6个字符以上")
		if (passString.test(val)) {
			$("#content .right .mima").find(".span3").html("OK").css("color","#090")
			count++
		}else{
			$("#content .right .mima").find(".span3").html("为了用户安全，建议至少为6个字符以上").css("color","#C8000A")
		}
		if(val==""){
			$("#content .right .mima").find("span3").html("密码不能为空").css("color","#C8000A")
		}
	})
	
	/********************确认密码注册失焦**********************/
	$("#content .right .mima").find("input").eq(1).blur(function(){
		var val = $(this).val()
		var val2 = $("#content .right .mima").find("input").eq(0).val()
		//$("#content .right .mima").find("input").eq(3).html("与上次输入的密码不符")
		if (val ==val2 &&val2 !="") {
			$("#content .right .mima").find(".span4").html("OK").css("color","#090")
			count++
		}else{
			$("#content .right .mima").find(".span4").html("密码不一致").css("color","#C8000A")
		}
		if(val==""){
			$("#content .right .mima").find(".span4").find("span").html("密码不能为空").css("color","#C8000A")
		}
	})
	
	/********************注册提交**********************/
	$("#content .right .agree .ag1 a").click(function(){
	
		//if(count>=4){
				var email = $(".email").val()
				var name = $(".name").val()
				var pass = $(".pass").val()
				setCookie("name", name)
				setCookie("pass", pass)
				setCookie("email",email)		//存cookie
				window.location.href = "fillcg.html";
		//		count = 0;						//cout归零防止count无限加大
		//}
	
   })
})
$(function(){
	
	var yhm= $("#content .mag p .span123").html(getCookie("name"));
	//alert(getCookie("name"))
   
    
    
})
 

/**************************登录*******************************/
$(function(){
	
		//if(name==getCookie("name")&&pass==getCookie("pass")){
		$("#content .left .down .one input").blur(function(){
		var name=$(".named").val();
		
		
		var val = $(this).val()
			
			if(name == getCookie("name")){
				$("#content .left .down .sp1").html("OK").css("color","#090")
			}else{
					$("#content .left .down .sp1").html("格式错误").css("color","#C8000A")
			}
			if(val==""){
				$("#content .left .down .sp1").html("账号不能为空").css("color","#C8000A")
			}

	    })
		
		$("#content .left .down .two input").blur(function(){
			var pass=$(".passd").val();
			var val = $(this).val();
			if(pass == getCookie("pass")){
				$("#content .left .down .sp2").html("OK").css("color","#090")
			}else{
					$("#content .left .down .sp2").html("格式错误").css("color","#C8000A")
			}
			if(val==""){
				$("#content .left .down .sp2").html("密码不能为空").css("color","#C8000A")
			}
		})
		
	   $("#content .left .down .three input").blur(function(){
			var yzm =$(".yzm").html();
			var inp =$(".down .three input").val();
			var val = $(this).val();
			if(yzm == inp){
				$("#content .left .down .sp3").html("OK").css("color","#090")
			}else{
					$("#content .left .down .sp3").html("格式错误").css("color","#C8000A")
			}
			if(val==""){
				$("#content .left .down .sp3").html("不能为空").css("color","#C8000A")
			}
		})
	   
	   $("#content .left .down .four input").click(function(){
	   	var name=$(".named").val();
	   	var pass=$(".passd").val();
	   	var yzm =$(".yzm").html();
		var inp =$(".down .three input").val();
	   	    if(name==getCookie("name")&&pass==getCookie("pass")&&yzm==inp){
	   	  	   alert("登陆成功")
	   	  	   setCookie("true",true,setCookieDate(7));
	   	       window.location.href = "index.html";
	   	    }else{
	   	    	alert("登录失败")
	   	    }
	   	   
	   })
		
})
	

























/******************************验证码***********************************/

    $(function(){
         var list =[0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
				
				$("#content .left .down .three a").click(function(){
					var a =Math.floor(Math.random()*36);
					var b =Math.floor(Math.random()*36);
					var c =Math.floor(Math.random()*36);
					var d =Math.floor(Math.random()*36);
					
				$("#content .left .down .three .yzm").html(list[a]+''+list[b]+''+list[c]+""+list[d]) ;
				})
					      	
    })
				



